package com.zff.rental.controller.room;


import com.zff.rental.AppConstant;
import com.zff.rental.annotation.EnableVerifyToken;
import com.zff.rental.common.Result;
import com.zff.rental.service.room.RoomStatisticsServer;
import com.zff.rental.vo.apartment.statistics.BrowsingRoomEndReq;
import com.zff.rental.vo.apartment.statistics.BrowsingRoomStartReq;
import com.zff.rental.vo.apartment.statistics.ClickContactRecordReq;
import jakarta.annotation.Resource;
import lombok.extern.log4j.Log4j2;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;


/**
 * 房间浏览统计
 *
 * @author HCY
 */
@Log4j2
@RestController
@RequestMapping(AppConstant.RM_ROOM_STATISTICS)
@EnableVerifyToken(false)
public class RoomStatisticsController {
    /**
     * 房间
     */
    @Resource
    protected RoomStatisticsServer roomStatisticsServer;

    /**
     * 用户开始浏览房间
     */
    @PostMapping("/startBrowsingRoom")
    public Result<Long> startBrowsingRoom(@Validated @RequestBody BrowsingRoomStartReq params) {
        Long id = roomStatisticsServer.startBrowsingRoom(params);
        return Result.success(id);
    }

    /**
     * 用户结束浏览房间
     */
    @PostMapping("/endBrowsingRoom")
    public Result<Object> endBrowsingRoom(@Validated @RequestBody BrowsingRoomEndReq params) {
        roomStatisticsServer.endBrowsingRoom(params);
        return Result.success(null);
    }

    /**
     * 点击联系记录
     */
    @PostMapping("/click")
    public Result<Object> clickContactRecord(@Validated @RequestBody ClickContactRecordReq params) {
        roomStatisticsServer.clickContactRecord(params);
        return Result.success(null);
    }
}